﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using RBAC.Repository;
using Traceability.Domain;
using Traceability.Service.Interfae;

namespace RBACDuYaJun.Api.Controllers
{
    /// <summary>
    /// 养殖信息/保健信息/养殖企业
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BreedsController : ControllerBase
    {
        /// <summary>
        /// 养殖服务
        /// </summary>
        private readonly IBreedService _breedService;
        /// <summary>
        /// 保健服务
        /// </summary>
        private readonly IHealthService _healthService;
        /// <summary>
        /// 养殖企业服务
        /// </summary>
        private readonly IBreedEnterpriseService _breedEnterpriseService;
        public BreedsController(IBreedService breedService, IHealthService healthService,
            IBreedEnterpriseService breedEnterpriseService)
        {
            _breedService = breedService;
            _healthService = healthService;
            _breedEnterpriseService = breedEnterpriseService;
        }


        /// <summary>
        /// 添加养殖信息
        /// </summary>
        /// <param name="breed"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddBreed(Breeds breed)
        {
           return await _breedService.AddBreed(breed);
        }
        /// <summary>
        /// 显示养殖信息
        /// </summary>
        /// <param name="bath"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Breeds>> GetBreeds(string bath)
        {
           return await _breedService.GetBreeds(bath);
        }
        /// <summary>
        /// 修改养殖信息
        /// </summary>
        /// <param name="breed"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateBreed(Breeds breed)
        {
            return await _breedService.UpdateBreed(breed);
        }
        /// <summary>
        /// 添加保健信息
        /// </summary>
        /// <param name="health"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddHealth(Health health)
        {
            return await _healthService.AddHealth(health);
        }
        /// <summary>
        /// 删除保健信息
        /// </summary>
        /// <param name="hid"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<int> DelHealth(int hid)
        {
            return await _healthService.DelHealth(hid);
        }
        /// <summary>
        /// 显示保健信息
        /// </summary>
        /// <param name="bath"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<Health>> GetHealth(string bath)
        {
            return await _healthService.GetHealth(bath);
        }
        /// <summary>
        /// 反填保健信息
        /// </summary>
        /// <param name="hid"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Health> GetHealthBy(int hid)
        {
           return await _healthService.GetHealthBy(hid);
        }
        /// <summary>
        /// 修改保健信息
        /// </summary>
        /// <param name="health"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<int> UpdateHealth(Health health)
        {
            return await _healthService.UpdateHealth(health);
        }
        /// <summary>
        /// 添加养殖企业
        /// </summary>
        /// <param name="breed"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddBreedEnterprise(BreedEnterprise breedEnterprise)
        {
            return await _breedEnterpriseService.AddBreedEnterprise(breedEnterprise);
        }
        /// <summary>
        /// 显示养殖企业
        /// </summary>
        /// <param name="bath"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<BreedEnterprise>> GetBreedEnterprise(string bath)
        {
           return await _breedEnterpriseService.GetBreedEnterprise(bath);
        }
        /// <summary>
        /// 修改养殖企业
        /// </summary>
        /// <param name="breedEnterprise"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateBreedEnterprise(BreedEnterprise breedEnterprise)
        {
            return await _breedEnterpriseService.UpdateBreedEnterprise(breedEnterprise);
        }
    }
}
